home *** CD-ROM | disk | FTP | other *** search
/ 130 MIDI Tool Box / 130 MIDI Tool Box.iso / mpu401 / record.c < prev    next >
C/C++ Source or Header  |  1986-11-02  |  1KB  |  60 lines

  1. /* Copyright (C) 1986 by M. J. Shannon, Jr.
  2. ** Permission to distribute for non-commercial uses granted as long as this
  3. ** notice is retained.  Violators will be prosecuted.
  4. */
  5.  
  6. #include    <stdio.h>
  7. #include    "mpu/mpu.h"
  8.  
  9. unsigned char read_buf[5120];    /* a buffer to read into */
  10.  
  11. int
  12. main(argc, argv, envp)
  13. int argc;
  14. char **argv;
  15. char **envp;
  16. {
  17.     char *vers_string;
  18.  
  19.     setbuf(stdout, NULL);
  20.     /* reset the MPU */
  21.     mpu_reset();
  22.     /* get the firmware version/revision */
  23.     vers_string = mpu_id();
  24.     /* show it to the user */
  25.     printf("MPU: %s\n", vers_string);
  26.     /* enable various options */
  27.     mpu_put(SWE_HEXCL);
  28.     mpu_put(SWE_DATAINSTOP);
  29.     mpu_put(SWE_TIME);
  30.     mpu_put(SWE_MODE);
  31.     mpu_put(SWE_BENDER);
  32.     mpu_put(SWE_MEASEND);
  33.     mpu_put(SWE_COMMON);
  34.     mpu_put(SWE_REALTIME);
  35.     if (argc > 1)
  36.         mpu_put(0x22);
  37.     /* and get packets until the user gives up */
  38.     for (;;)
  39.     {
  40.         int length, i;
  41.         unsigned char c;
  42.  
  43.         length = mpu_read(&read_buf[0]);
  44.         if (length)
  45.         {
  46.             printf("Length = %d:\n", length);
  47.             for (i = 0; i < length; ++i)
  48.             {
  49.                 c = read_buf[i];
  50.                 printf("%x%x ", (c >> 4) & 0x0F, c & 0x0F);
  51.             }
  52.             printf("\n");
  53.         }
  54.         else
  55.             printf(" \b \b \b");
  56.     }
  57.     /* return success to DOS */
  58.     return (0);
  59. }
  60.